﻿using DMSkin.Core.MVVM;
using DMSkin.WeChat.API;
using DMSkin.WeChat.View;
using DMSkin.WeChat.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;

namespace DMSkin.WeChat.Model
{
    /// <summary>
    /// 好友
    /// </summary>
    public class Friend : ViewModelBase
    {
        private string source;
        private string date;
        private string username;
        private string message;
        private ObservableCollection<Message> messages;
        private Visibility visible;

        public string Source { get { return source; } set { source = value; OnPropertyChanged("Source"); } }
        public string Date { get { return date; } set { date = value;OnPropertyChanged("Date"); } }
        public string Username { get { return username; } set { username = value;OnPropertyChanged("Username"); } }
        public string Message { get { return message; } set { message = value;OnPropertyChanged("Message"); } }
        public ObservableCollection<Message> Messages { get { return messages; } set { messages = value; OnPropertyChanged("Messages"); } }
        public Visibility Visible { get { return visible; } set { visible = value;OnPropertyChanged("Visible"); } }

        #region
        /// <summary>
        /// 改变页面
        /// </summary>
        public ICommand OnWeChatCommand => new DelegateCommand((sender) =>
        {
            if (sender is ChatListPage chatListPage)
            {
                if (chatListPage.DataContext is ChatListPageViewModel chatListPageViewModel)
                {
                    chatListPageViewModel.CurrentPage = PageManager.wechatPage;
                    if (PageManager.wechatPage.DataContext is WechatPageViewModel wechatPageViewModel)
                    {
                        wechatPageViewModel.Username = this.Username;
                        wechatPageViewModel.Messages = this.Messages;
                    }
                }
            }
        });
        #endregion
    }
}
